﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Vux.Chart.Objects;

namespace TestLineChart
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.lineChart1.AddSeries("Đồ thị sin", Color.Red, 2, true);
            this.lineChart1.AddSeries("Đồ thị Cos", Color.DarkBlue, 2, true);
        }

        private int n = 100;

        private double[,] GetSeries()
        {
            var data = new double[n, 2];
            var random = new Random();
            for (int i = 0; i < n; i++)
            {
                data[i, 0] = i;
                data[i, 1] = Math.Sin(i); //Math.Pow(i, 2);//
            }
            return data;
        }

        private double[,] GetCosSeries()
        {
            var data = new double[n, 2];
            var random = new Random();
            for (int i = 0; i < n; i++)
            {
                data[i, 0] = i;
                data[i, 1] = Math.Cos(i); //Math.Pow(i, 2);//
            }
            return data;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var data = GetSeries();
            this.lineChart1.RangeX = new Vux.Chart.Objects.DoubleRange(0, n);
            this.lineChart1.UpdateSeries("Đồ thị sin", data);

            data = GetCosSeries();
            this.lineChart1.RangeX = new Vux.Chart.Objects.DoubleRange(0, n);
            this.lineChart1.UpdateSeries("Đồ thị Cos", data);
        }
    }
}
